var { gUtils, clickUtils, logUtils, appUtils } = require("../../utils/index");
var { App } = require("../base/index");
var pointMap = require("./pointMap/pointMap");

var xiGua = new App("西瓜视频", {
  maxCount: 30,
  interval: 10 * 60,
  autoClose: true,
});
xiGua.run = function (count) {
  if (count > 3) {
    this.watchVideo(count);
  } else {
    gUtils.sleep(20, 60);
  }
};
xiGua.watchVideo = function (count) {
  var countIndex =
    count > 10 ? 5 + gUtils.random(1, 5) : 2 + gUtils.random(1, 2);
  logUtils.log("将看视频" + countIndex + "次");
  for (var index = 0; index < countIndex; index++) {
    gUtils.sleep(60, 120);
    this.nextVideo();
  }
};
xiGua.nextVideo = function () {
  if (gUtils.possible(1, 10)) {
    appUtils.home(this.appName);
    gUtils.sleep(2, 4);
  }
  logUtils.log("将看下一个视频");
  if (gUtils.possible(1, 20)) {
    logUtils.log("back()");
    back();
  } else {
    logUtils.log("点击首页");
    clickUtils.clickPointMap(pointMap.首页.首页);
  }
  gUtils.sleep(3, 6);
};
module.exports = xiGua;
